<?php
session_start();
ini_set("include_path", "/");
require_once 'ClsSebent/Product_class.php';//C:/Program Files/EasyPHP 2.0b1/www/SebentLastCode
$_SESSION['PRODUCT_ID']=4;
$_SESSION['USERTYPE']='buyer';
$_SESSION['SITE_ID']=101;

	$Product= new Product_class;
	$Product->Product_id=$_SESSION["PRODUCT_ID"];
	$Product->Site_id=$_SESSION["SITE_ID"];
	$Product->Select_Product();
	
	if(isset($_POST["btn_Update_Master"]))
	{	
		if($Product->Check_ProductOwner())
		{
			$Product->Check_ProductOwner();//echo "*".$_POST["Product_price"];
			//$Product->Site_id=$_SESSION["SITE_ID"];
			$Product-> Product_title=$_POST['Product_title'];
			$Product-> Product_price=$_POST['Product_price'];	
			$Product-> Product_cat=$_POST['Product_cat'];
			$Product-> Product_desc=$_POST['Product_desc'];
			$Product-> Product_size=$_POST['Product_size'];
			$Product-> Product_color=$_POST['Product_color'];
			$Product-> Product_imgurl=$_FILES['Product_imgurl']['tmp_name'];
			$Product-> Product_imgalt=$_POST['Product_imgalt'];	
			//*******************************
			$Product-> addonFileName=$_FILES['addonFileName']['tmp_name'];
			$Product-> lotpriceFileName=$_FILES['lotpriceFileName']['tmp_name'];			
			$Product->Update_Product();			
		}
	}
	if(isset($_POST["btn_Update_LocalSettings"]))
	{		
		$Product->Profit_amt=$_POST["Profit_amt"];
		$Product->Profit_on=$_POST["Profit_on"];
		$Product->Tax_amt=$_POST["Tax_amt"];		
		$Product->Tax_on=$_POST["Tax_on"];
		$Product->Shipping_amt=$_POST["Shipping_amt"];
		$Product->Update_ProductSettings();		
	}
?>
<form action="product_update.php" method="post" enctype="multipart/form-data">
<script src="ClsSebent/Client_Validation.js" type="text/javascript"></script>
  <table width="100%" border="1">
    <tr>
      <td colspan="3"><div align="center"><strong>Update Product </strong></div></td>
    </tr>
    <tr>
      <td colspan="3"><div id="divMessage" align="center"><?php echo "<h2><font color='red'>".$Product->Message."</font></h2>";?></div></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">Update Product Master </div></td>
    </tr>
    <tr>
      <td colspan="2" valign="baseline">&nbsp;</td>
      <td width="15%"><img src="<?php echo $Product->Product_imgurl; ?>" width="150" height="150"></td>
    </tr>	
    <tr>
      <td width="19%">Product Category </td>
      <td colspan="2">
	  <input type="text" name="category" id="category" value="<?php OpenConnection(); echo $Product->Select_Category(); CloseConnection();?>">
	  &nbsp; Select a new Category
	  <select name="Product_cat">
	<?php $Product->Load_categories(); ?>
    </select>
	<script type="text/javascript">
		var Cat_List=document.getElementById('Product_cat');
		Cat_List.selectedIndex=0;		
	</script>  
	  </td>
    </tr>	
    <tr>
      <td>Product Name </td>
      <td colspan="2"><input type="text" id="Product_title" name="Product_title" value="<?php echo $Product->Product_title; ?>"></td>
    </tr>
    <tr>
      <td>Product Description </td>
      <td colspan="2"><textarea id="Product_desc" name="Product_desc" cols="30" rows="5"><?php echo $Product->Product_desc; ?></textarea></td>
    </tr>
    <tr>
      <td>Size</td>
      <td colspan="2"><input type="text" name="Product_size" id="Product_size" value="<?php echo $Product->Product_size; ?>"></td>
    </tr>
    <tr>
      <td>Color</td>
      <td colspan="2"><input type="text" name="Product_color" id="Product_color" value="<?php echo $Product->Product_color; ?>"></td>
    </tr>
    <tr>
      <td>Price</td>
      <td colspan="2"><input type="text" name="Product_price" id="Product_price" value="<?php echo $Product->Product_price; ?>"></td>
    </tr>
    <tr>
      <td>Image</td>
      <td colspan="2"><input type="file" name="Product_imgurl" id="Product_imgurl"></td>
    </tr>
    <tr>
      <td>Image Alt</td>
      <td colspan="2"><input type="text" name="Product_imgalt" value="<?php echo $Product->Product_imgalt; ?>"></td>
    </tr>
    <tr>
      <td>Add On List </td>
      <td colspan="2"><input type="file" name="addonFileName"></td>
    </tr>
    <tr>
      <td>Lot Pricing List </td>
      <td colspan="2"><input type="file" name="lotpriceFileName"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">
        <input name="btn_Update_Master" type="submit" id="btn_Update_Master" value="Update Master Product" onClick="javascript: return validate_UpdateProduct();">
      </div></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">Update Local Settings</div></td>
    </tr>
    <tr>
      <td>Profit % </td>
      <td width="66%"><input type="text" name="Profit_amt" id="Profit_amt" value="<?php echo $Product->Profit_amt; ?>"></td>
      <td width="15%"><input type="checkbox" name="Profit_on" <?php if($Product->Profit_on=='Y')echo 'checked value="Y"'; ?> id="Profit_on" >
        Apply Profit </td>
    </tr>
    <tr>
      <td>Tax % </td>
      <td><input type="text" name="Tax_amt" id="Tax_amt" value="<?php echo $Product->Tax_amt; ?>"></td>
      <td><input type="checkbox" name="Tax_on" <?php if($Product->Tax_on=='Y')echo 'checked value="Y"'; ?> id="Tax_on">
        Apply Tax </td>
    </tr>
    <tr>
      <td>Shipping</td>
      <td colspan="2"><input type="text" name="Shipping_amt" id="Shipping_amt" value="<?php echo $Product->Shipping_amt; ?>"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="center">
          <input name="btn_Update_LocalSettings" type="submit" id="btn_Update_LocalSettings" onClick="javascript: return validate_UpdateProductSettings();" value="Update Local Settings">
      </div></td>
    </tr>
  </table>
</form>
